import { S } from '../../s';
import { IPSAppFunc } from './ipsapp-func';
import { IPSAppView } from '../view/ipsapp-view';
import { IPSNavigateContext } from '../../control/ipsnavigate-context';
import { IPSNavigateParam } from '../../control/ipsnavigate-param';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSUIAction } from '../../view/ipsuiaction';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppFuncImpl extends PSModelObjectImpl implements IPSAppFunc {
  get appFuncType():
    | 'APPVIEW'
    | 'OPENHTMLPAGE'
    | 'PDTAPPFUNC'
    | 'UIACTION'
    | 'JAVASCRIPT'
    | 'CUSTOM' {
    return this.M.appFuncType;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get funcSN(): string {
    return this.M.funcSN;
  }

  get htmlPageUrl(): string {
    return this.M.htmlPageUrl;
  }

  get jSCode(): string {
    return this.M.jSCode;
  }

  protected namepslanguageres: IPSLanguageRes;
  getNamePSLanguageRes(): IPSLanguageRes | null {
    return (
      this.namepslanguageres ||
      (this.namepslanguageres = this.fillObjectModel(
        S._276,
        this.M.getNamePSLanguageRes,
        S._2bd,
      ) as IPSLanguageRes)
    );
  }

  get openMode():
    | 'INDEXVIEWTAB'
    | 'INDEXVIEWPOPUP'
    | 'INDEXVIEWPOPUPMODAL'
    | 'HTMLPOPUP'
    | 'TOP' {
    return this.M.openMode;
  }

  get openViewParam(): IModel {
    return this.M.openViewParam;
  }

  protected psappview: IPSAppView;
  getPSAppView(): IPSAppView | null {
    return (
      this.psappview ||
      (this.psappview = this.fillObjectModel(
        S._1e,
        this.M.getPSAppView,
        S._2c4,
      ) as IPSAppView)
    );
  }

  protected psnavigatecontexts: IPSNavigateContext[];
  getPSNavigateContexts(): IPSNavigateContext[] | null {
    return (
      this.psnavigatecontexts ||
      (this.psnavigatecontexts = this.fillChildListModel(
        this.M.getPSNavigateContexts,
        S._8c,
      ) as IPSNavigateContext[])
    );
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5(
      S._8c,
      this.getPSNavigateContexts(),
      objKey,
    ) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[];
  getPSNavigateParams(): IPSNavigateParam[] | null {
    return (
      this.psnavigateparams ||
      (this.psnavigateparams = this.fillChildListModel(
        this.M.getPSNavigateParams,
        S._8a,
      ) as IPSNavigateParam[])
    );
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5(
      S._8a,
      this.getPSNavigateParams(),
      objKey,
    ) as IPSNavigateParam;
  }

  getPSPDTAppFuncId(): string {
    return this.M.getPSPDTAppFuncId;
  }

  protected psuiaction: IPSUIAction;
  getPSUIAction(): IPSUIAction | null {
    return (
      this.psuiaction ||
      (this.psuiaction = this.fillObjectModel(
        S._29d,
        this.M.getPSUIAction,
        S._2de,
      ) as IPSUIAction)
    );
  }

  get tooltip(): string {
    return this.M.tooltip;
  }

  protected tooltippslanguageres: IPSLanguageRes;
  getTooltipPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.tooltippslanguageres ||
      (this.tooltippslanguageres = this.fillObjectModel(
        S._276,
        this.M.getTooltipPSLanguageRes,
        S._2c5,
      ) as IPSLanguageRes)
    );
  }

  get userData(): string {
    return this.M.userData;
  }

  get userData2(): string {
    return this.M.userData2;
  }

  get systemReserved(): boolean {
    return this.M.systemReserved != null ? this.M.systemReserved : false;
  }
  get cls(): string {
    return 'PSAppFuncImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._10 || cls == S._7) return true;
    return super.instanceof(cls);
  }
}
